package display {
	// import components.NodeToolTip;
	
	import flare.display.DirtySprite;
	import flare.vis.data.NodeSprite;
	
	import flash.display.Sprite;
	import flash.net.URLRequest;
	
	import mx.containers.Panel;
	
	import org.aswing.ASFont;
	import org.aswing.AsWingManager;
	import org.aswing.AssetPane;
	import org.aswing.BorderLayout;
	import org.aswing.Container;
	import org.aswing.JLabel;
	import org.aswing.JLoadPane;
	import org.aswing.JPanel;
	import org.aswing.JTextComponent;
	import org.aswing.JTextField;
	import org.aswing.JWindow;
	import org.aswing.SoftBoxLayout;
	import org.aswing.border.LineBorder;
	
	import spark.components.VGroup;
	
	import struct.User;

	public class NodeToolTipSprite extends Sprite {
		public var window:JWindow;
		public var avatar:JLoadPane;
		public var nickname:JTextField;
	    public function NodeToolTipSprite() {
			super();
			AsWingManager.initAsStandard(this);
			window = new JWindow();
			var pane:Container = window.getContentPane();
			pane.setLayout(new BorderLayout());
			avatar = new JLoadPane(null, AssetPane.PREFER_SIZE_LAYOUT);
			avatar.setSizeWH(50, 50);
			nickname = new JTextField();
			nickname.setEditable(false);
			nickname.setFont(new ASFont("Tahoma", 12, true, true));
			// nickname.setSizeWH(250, 50);
			var menuContainer:JPanel = new JPanel();
			var toolContainer:JPanel = new JPanel();
			var tasksContainer:JPanel = new JPanel();
			var statusContainer:JPanel = new JPanel();
			var top:JPanel = new JPanel(new SoftBoxLayout(SoftBoxLayout.X_AXIS));
			top.append(avatar);
			top.append(nickname);
			// top.append(toolContainer);
			pane.append(top, BorderLayout.NORTH);
			pane.append(tasksContainer, BorderLayout.CENTER);
			pane.append(statusContainer, BorderLayout.SOUTH);
			// pane.append(avatar, BorderLayout.SOUTH);
			//给每个部分添加标签以观察布局
			addLabel(menuContainer, "菜单部分");
			addLabel(toolContainer, "工具栏部分");
			addLabel(tasksContainer, "日程列表部分");
			addLabel(statusContainer, "状态栏部分");
			window.setSizeWH(300, 200);
			// this.addChild(window);
			// window.show();
		}
		private function addLabel(pane:JPanel, label:String): void{
			pane.append( new JLabel(label));
			//给容器设置一个边框以观察大小范围
			pane.setBorder( new LineBorder());
		}
		public function update(n:NodeSprite):void {
			var url:String = n.data.picture;
			avatar.load(new URLRequest(url));
			nickname.appendByReplace(n.data.name);
		}
	}
}